{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-body">
            <form action="" class="layui-form" method="get">
                <div class="layui-form-item layui-form-pane">
                    <div class="layui-inline">
                        <label class="layui-form-label">订单号：</label>
                        <div class="layui-input-inline">
                            <input name="order_sn" class="layui-input" id="title" value="" type="text"
                                   placeholder="请输入订单号">
                        </div>
                    </div>
<!--                    <div class="layui-form-item">-->
<!--                        <label class="layui-form-label">支付状态 *</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <select name="status" lay-verify="required" >-->
<!--                                <option value="1" >启用</option>-->
<!--                                <option value="0" >禁用</option>-->
<!--                            </select>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-inline">
                        <label class="layui-form-label">支付状态：</label>
                        <div class="layui-input-inline">
                            <select name="pay_status" >
                                <option value="" >请选择</option>
                                <option value="0" >未支付</option>
                                <option value="1" >已支付</option>
                                <option value="-1" >已退款</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <button class="layui-btn icon-btn layui-btn-sm" data-id="table_id" lay-filter="search"
                                lay-submit="">
                            <i class="layui-icon"></i>搜索
                        </button>
                        <button type="reset" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i
                                class="layui-icon layui-icon-refresh"></i>{:__('Reset')}
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>


    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="table_id" lay-filter="table_id"></table>
        </div>
    </div>

</div>
{/block}

{block name="js"} <!--js处理区-->


<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button type="button" lay-event="add" class="layui-btn {:node('Admin/addAdmin')} layui-btn-sm">添加安保人员</button>
        <button type="button" lay-event="del" class="layui-btn {:node('Admin/del')} layui-btn-sm layui-btn-danger">
            删除安保人员
        </button>
        <button type="button" lay-event="reload" class="layui-btn  layui-btn-sm  layui-btn-primary">刷新表格</button>
    </div>
</script>
<script>
    layui.use(['element', 'table', 'form', 'jquery', 'lucky', 'opTable'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var lucky = layui.lucky;
        var opTable = layui.opTable;
        form.render();
        var myTables = table.render({
            elem: '#table_id',
            url: "{:url('index')}",
            // toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports', 'print'],
            even: true, //开启隔行背景
            id: 'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip', 'last'] //自定义分页布局
                , groups: 5 //只显示 1 个连续页码
                , first: false //不显示首页
                , last: false //不显示尾页
                , limit: 20
                , limits: [10, 20, 30, 50]
            },
              // height: 'full-100',100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                {title: '名称', field: 'name'},
                {title: '单价', field: 'amount',edit:true},
                {title: '单位', field: 'id',templet:function (re) {
                       return '元'
                }},

            ]],
            //  展开的列配置
            openCols: [
                {field: 'desc', title: '描述信息'}
            ],
            done: function (res) {
                layer.closeAll('loading');
            }
        });
        table.on('edit(table_id)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            console.log('value',value)
            console.log('data',data)
            console.log('field',field)
            $.ajax({
                url:"{:url('editInfo')}",
                type:"post",
                data: {'id':data.id,'amount':value},
                dataType:"json",
                success:function(data){
                    var param = data.data
                    for (var i =0;i< param.length;i++){
                        param[i].amount = 0
                    }
                    student_table.reload(data);
                }
            });

        });




        /**
         * 关键词搜索树
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch(obj.field);
            return false;
        });
    });

</script>

{/block}
